<?php

require_once 'Base.php';

class AddressModel extends Base {
	
	
	
	public function updateuser($data,$where){
		$this->_db = $this->getAdapter();
		//$where = $this->_db->quoteInto('id = ?', $id);//条件
		
		$res=$this->_db->update($this->_table,$data,$where);
		return $res;
		
	}
	
	public function getOne($where){
	
		$this->_table='shop_user_address';
		$this->_db = $this->getAdapter();
		$select = $this->_db->select();
		$select->from($this->_table);
	
		foreach ($where as $key => $val) {
			if (is_int($key)) {
				$select->where($val);
			} else {
				$select->where($key, $val);
			}
		}
	
		return $this->_db->fetchRow($select);
	}
	
	public function getList($where){
	
		$this->_table='shop_user_address';
		$this->_db = $this->getAdapter();
		$select = $this->_db->select();
		$select->from($this->_table);
		
		foreach ($where as $key => $val) {
			if (is_int($key)) {
				$select->where($val);
			} else {
				$select->where($key, $val);
			}
		}
		
	   return $this->_db->fetchAll($select);
	}
	
	public function deladress($where){
		$this->_table='shop_user_address';
		$this->_db = $this->getAdapter();
		$res=$this->_db->delete($this->_table,$where);
		return $res;
	}
	
	public function addadress($data, $where=''){
		$this->_table='shop_user_address';
		$this->_db = $this->getAdapter();
	   if($where){
	   	$res=$this->_db->update($this->_table,$data,$where);
	   }else{
	   	//print_r($data);
	    $res=$this->_db->insert($this->_table,$data);
	   }
       return $res;
       // print_r($data);
      
    
       // return $this->_db->lastInsertId();
		//print_r($smsCodeend); die();
	}
	
	
}
